package com.fengsh.nacos.api.controller;

import com.fengsh.nacos.api.Service1Api;
import com.fengsh.nacos.api.feign.CallService2FeignApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @标题
 * @作者 fengsh998
 * @创建时间 2024/1/29
 * @功能描述
 */

@RestController
public class Service1Controller {
    @Autowired
    Service1Api serviceApi;

    //远程Feign调用服务2的接口
    @Autowired
    CallService2FeignApi s2Api;

    @GetMapping("/service1")
    public String readServiceApi() {
        return "Service 1 Controller " + serviceApi.service();
    }

    /**
     * 通过使用Feign调用服务2中的接口获取数据。
     * @return
     */
    @GetMapping("/name")
    public String readService2Name() {
        String name = s2Api.toCallService2Data();
        return "Service1 to call Service2 Get Name：" + name;
    }
}
